package com.tedu.webDemo.controller;

import java.util.UUID;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IndexController {
	@RequestMapping("/index")
	public String index(HttpServletResponse response) {
		//创建临时的cookie,浏览器一关，就没了
		String id1=UUID.randomUUID().toString();
		Cookie cookie=new Cookie("baidu_id1", id1);
		response.addCookie(cookie);
		
		//长期的cookie,浏览器关了，还存在
		String id2=UUID.randomUUID().toString();
		Cookie cookie2=new Cookie("baidu_id2", id2);
		cookie2.setMaxAge(60*3);//有效期是3分钟
		response.addCookie(cookie2);
		
		return "设置cookie";
	}

}
